
function _getValueMap(options){
    let map={};
    options.forEach((itemObj)=>{
        map[itemObj["value"]]=itemObj["label"];
    })
    return map;
}

export {_getValueMap};
export default [
    {id:'resourceTypeValue',label:'资源类型',width:100,value:'',required:true,sortable:true,editorType:'selectDrop',show:true,},
    {id:'dictionaryName',label:'名称',value:'',required:true,sortable:true,editorType:'input',show:true,maxLength:20},
    {id:'dictionaryCode',label:'编码',value:'',required:true,sortable:true,editorType:'input',show:true,maxLength:20},
    {id:'dictionaryValueType',label:'字段类型',width:100,value:'1',required:true,sortable:true,editorType:'selectDrop',show:true,options:[{
            value: '1',
            label: '输入框'
        },{
            value: '2',
            label: '下拉框'
        },{
            value: '3',
            label: '组合'
        },{
            value: '4',
            label: '组合数组'
        }],optionsMap:{'1':'输入框','2':'下拉框','3':'组合','4':'组合数组'}},
    {id:'dictionaryValues',label:'枚举值',width:100,value:'',required:true,sortable:true,editorType:'input',show:false,remark:"数据格式：code=硬盘;code2=硬盘2",maxLength:50},
    {id:'dictionaryIds',label:'组合字段',width:100,value:[],gridShow:false,required:true,sortable:true,editorType:'selectDrop',multiple:true,show:false,options:[],},
    {id:'showAttributeStatus',label:'是否展示到列表',width:150,value:'1',required:true,sortable:true,editorType:'selectDrop',show:true,options:[{
            value: '0',
            label: '不展示'
        },{
            value: '1',
            label: '展示'
        }],optionsMap:{'0':'不展示','1':'展示'},cellFun:(rowRecord,itemd)=>{
            if((rowRecord[itemd]+"")==="0"){
                return '不展示'
            }else{
                return '展示';
            }
        }},
    {id:'coreAttributeStatus',label:'是否是核心字典',width:150,value:'1',required:true,sortable:true,editorType:'selectDrop',show:true,options:[{
            value: '0',
            label: ' 不是'
        },{
            value: '1',
            label: '是'
        }],optionsMap:{'0':'不是','1':'是'},cellFun:(rowRecord,itemd)=>{
            if((rowRecord[itemd]+"")==="0"){
                return '不是'
            }else{
                return '是';
            }
        }},
]

let _initColWidth=function (cols) {
    let totalWidth=document.body.clientWidth-240-180;
    let colTotalWid=0;
    cols.forEach((item)=>{
        colTotalWid=parseFloat(colTotalWid)+parseFloat(item.width)
    });
    //如果存在多余的宽度，则将多余的宽度平均分配到其他列去
    if(colTotalWid<totalWidth){
        let oWid=totalWidth-colTotalWid;
        let oWidNum=oWid/cols.length;
        cols.forEach((itemObj)=>{
            itemObj["width"]=itemObj["width"]+oWidNum;
        })
    }
}
export {_initColWidth};


let _changToAddDomain=function (cols) {
    let dbField={};
    cols.forEach((itemObj,index)=>{
        dbField[itemObj.id]=itemObj.value;
    });
   return dbField;
}

export {_changToAddDomain};

let _getCloneCols=function (cols) {
    let newCols=[];
    cols.forEach((itemObj)=>{
        newCols.push({...itemObj});
    })
    return newCols;
}

export {_getCloneCols};